
#version 330 core
out vec3 color;
smooth in vec2 uv;
smooth in vec2 dir;
uniform sampler2D scene;
uniform float amount;

vec3 scatter(sampler2D s, int quality, float decay)
{
	vec3 result = vec3(0);
	for (int i=0; i<quality; i++)
		result += texture(s, uv + dir*i/quality).rgb * mix(1, float(i) / quality, decay);
	return result / quality;
}

void main()
{
	color = scatter(scene, 100, 0.5) * smoothstep(0, 1, amount);
	//if (length(dir) < 0.05) color = vec3(0, 1, 0);	// debug helper
}


